<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**  Policies Page **/
class Policies extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model("policiess");
		$this->load->helper('text');
	}
	 
    public function add(){
		$value['title']	  = "Policies";
		$value['content'] = "vpolicies/vadd";
		$this->load->view('themes/bdo/index',$value);
	}
    
	public function uploadFile(){
		$config['upload_path'] = './assets/policies/';
		$config['allowed_types'] = 'pdf|xls|xlsx|doc|docx';
		$config['max_size']	   = '0';
		$config['max_width']   = '0';
		$config['max_height']  = '0';
		$config['file_name']   = date('Y-m-d').'-'.seoUrl($this->input->post('title'));
		$this->load->library('upload',$config);
		if (!$this->upload->do_upload('file')):
			$data = '';
		else:
			$data = $this->upload->data();
		endif;
		
		if(!empty($data))
			$file = $data['file_name'];
		else
			$file = '';
		return $file;
	}
	
	public function save(){
		$file = $this->uploadFile(); // call file
		$this->policiess->saveFile($file);
		redirect($this->input->server('HTTP_REFERER'),301);
	}
    
	public function removeFile($id){
		$this->policiess->removeFile($id);
		redirect($this->input->server('HTTP_REFERER'),301);
	}
}

/* End of file policiess.php */
/* Location: ./application/controllers/policies.php */